<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <!--设置过期时间设置0为直接过期并清除缓存-->
    <meta http-equiv="Expires" content="0">
    <!--设置不缓存页面-->
    <meta http-equiv="Pragma" content="no-cache">
    <!--设置不修改消息存储-->
    <meta http-equiv="Cache-control" content="no-cache">
    <!--同上-->
    <meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9">
    <meta charset="UTF-8">
    <script src="./static/echarts/index.js"></script>
    <script src="./static/map/city.js"></script>
    <script src="./static/map/worldJson.js"></script>
    <script src="./static/map/world.js"></script>
    <script src="./static/map/shandong.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=1XjLLEhZhQNUzd93EjU5nOGQ"></script>
    <script type="text/javascript" src="./static/mapv/mapv.js"></script>
    <!--    <script src="https://cdn.bootcss.com/echarts/4.0.0/echarts.min.js"></script>-->
</head>

<body>

    <div id="app"></div>

</body>
<script>
    (function(root, factory) {
        if (typeof define === 'function' && define.amd) {
            // AMD. Register as an anonymous module.
            define(['exports', 'echarts'], factory);
        } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
            // CommonJS
            factory(exports, require('echarts'));
        } else {
            // Browser globals
            factory({}, root.echarts);
        }
    }(this, function(exports, echarts) {
        var log = function(msg) {
            if (typeof console !== 'undefined') {
                console && console.error && console.error(msg);
            }
        }
        if (!echarts) {
            log('ECharts is not Loaded');
            return;
        }
        if (!echarts.registerMap) {
            log('ECharts Map is not loaded')
            return;
        }
        echarts.registerMap('world', WORLDJSON);
        echarts.registerMap('world1', WORLD)
        echarts.registerMap('shandong', shandong)
    }))

    // 对世界地图的json文件中的经纬度坐标进行处理
    const processLng = lng => {
        if (lng > -30) {
            lng = lng - 180
        } else {
            lng = lng + 180
        }
        return lng
    }
    //格林兰岛表现怪异
    const processLngGe = lng => {
        return lng + 180
    }
    WORLDJSON.features.map((district, index) => {
        if (district.properties.name == 'Greenland') {
            // WORLDJSON.features.splice(index, 1)
            if (district.geometry.type == 'Polygon') {
                district.geometry.coordinates.map(border => {
                    border.map(coord => {
                        coord[0] = processLngGe(coord[0])

                    })
                })
            } else {
                district.geometry.coordinates.map(border => {
                    border.map(coordinates => {
                        coordinates.map(coord => {
                            coord[0] = processLngGe(coord[0])
                        })
                    })
                })
            }
        } else {
            if (district.geometry.type == 'Polygon') {
                district.geometry.coordinates.map(border => {
                    border.map(coord => {
                        coord[0] = processLng(coord[0])

                    })
                })
            } else if (district.geometry.type == 'LineString') {
                //    console.log(district.geometry.coordinates)
                district.geometry.coordinates.map((item) => {

                })
            } else {
                district.geometry.coordinates.map(border => {
                    border.map(coordinates => {

                        coordinates.map(coord => {
                            coord[0] = processLng(coord[0])
                        })
                    })
                })
            }
        }

    })
    var linesEndCoords = {}
    for (var item in CITYMAP) {
        let lng = CITYMAP[item][0]
        if (CITYMAP[item][0] > -30) {
            CITYMAP[item][0] = CITYMAP[item][0] - 180
        } else {
            CITYMAP[item][0] = CITYMAP[item][0] + 180
        }
        if (CITYMAP[item][0] < 0) {
            linesEndCoords[item] = [CITYMAP[item][0] - 20, CITYMAP[item][1] + 15]
        } else {
            linesEndCoords[item] = [CITYMAP[item][0] + 20, CITYMAP[item][1] + 15]
        }
    }
    var nineData = [
        [{
                coord: [
                    107.666015625,
                    17.308687886770034
                ],
            },
            {
                coord: [
                    109.2041015625,
                    15.580710739162123
                ]
            }
        ],
        [{
                coord: [
                    110.4345703125,
                    13.15437605541853
                ],
            },
            {
                coord: [
                    109.8193359375,
                    10.660607953624776
                ]
            },

        ],
        [{
                coord: [
                    108.017578125,
                    7.667441482726068
                ],
            },
            {
                coord: [
                    107.666015625,
                    5.178482088522876
                ]
            }
        ],
        [{
                coord: [
                    110.6982421875,
                    3.381823735328289
                ],
            },
            {
                coord: [
                    113.15917968749999,
                    4.565473550710278
                ]
            }
        ],
        [{
                coord: [
                    114.7412109375,
                    6.227933930268672
                ],
            },
            {
                coord: [
                    116.19140625,
                    8.059229627200192
                ]
            }
        ],
        [{
                coord: [
                    110.6982421875,
                    3.381823735328289
                ],
            },
            {
                coord: [
                    113.15917968749999,
                    4.565473550710278
                ]
            }
        ],
        [{
                coord: [
                    114.7412109375,
                    6.227933930268672
                ],
            },
            {
                coord: [
                    116.19140625,
                    8.059229627200192
                ]
            }
        ],
        [{
                coord: [
                    110.6982421875,
                    3.381823735328289
                ],
            },
            {
                coord: [
                    113.15917968749999,
                    4.565473550710278
                ]
            }
        ],
        [{
                coord: [
                    114.7412109375,
                    6.227933930268672
                ],
            },
            {
                coord: [
                    116.19140625,
                    8.059229627200192
                ]
            }
        ],
        [{
                coord: [
                    117.2900390625,
                    9.665738395188692
                ],
            },
            {
                coord: [
                    118.6083984375,
                    11.480024648555816
                ]
            }
        ],
        [{
                coord: [
                    119.35546875000001,
                    12.811801316582619
                ],
            },
            {
                coord: [
                    119.35546875000001,
                    15.326571801420842
                ]
            }
        ],
        [{
                coord: [
                    119.267578125,
                    16.678293098288513
                ],
            },
            {
                coord: [
                    120.1904296875,
                    19.02057711096681
                ]
            }
        ],
        [{
                coord: [
                    120.7177734375,
                    20.2209657795223
                ],
            },
            {
                coord: [
                    121.81640624999999,
                    22.105998799750566
                ]
            }
        ],
        [{
                coord: [
                    122.1240234375,
                    22.917922936146045
                ],
            },
            {
                coord: [
                    123.31054687499999,
                    24.647017162630366
                ]
            }
        ],
    ]
    //对九段线进行偏移
    nineData.map((item, index) => {
        item.map((it, ind) => {
            it.coord[0] -= 180
            //            console.log(it.coord[0])
        })
    })

</script>

</html>
